package com.zzyl.controller.security;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.LoginDto;
import com.zzyl.service.UserService;
import com.zzyl.vo.LoginVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/security")
@Api(tags = "后台登录")
public class LoginController {
    @Autowired
    private UserService userService;

    /**
     * 后台用户登录
     *
     * @param dto 用户登录Dto
     * @return {@code ResponseResult<LoginVo> }
     * @author YiSheep
     */
    @ApiOperation("后台用户登录")
    @PostMapping("/login")
    public ResponseResult<LoginVo> login(@RequestBody LoginDto dto) {
        log.info("后台用户登录:{}", dto);
        LoginVo loginVo = userService.login(dto);
        return ResponseResult.success(loginVo);
    }
}
